package com.zs.controller.btrace;

import com.zs.common.model.DemoUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/btrace")
@Slf4j
public class BtraceController {

    @RequestMapping("/arg1")
    public String arg1(@RequestParam("name") String name) {
        return "hello," + name;
    }

    @RequestMapping("/arg2")
    public DemoUser arg2(DemoUser DemoUser) {
        return DemoUser;
    }

    @RequestMapping("/constructor")
    public DemoUser constructor(DemoUser DemoUser) {
        return DemoUser;
    }

    @RequestMapping("/same1")
    public String same(@RequestParam("name") String name) {
        return "hello," + name;
    }

    @RequestMapping("/same2")
    public String same(@RequestParam("name") String name, @RequestParam("id") int id) {
        return "hello," + name + "," + id;
    }

    @RequestMapping("/exception")
    public String exception() {
        try {
            System.out.println("start...");
            System.out.println(1 / 0);
            System.out.println("end...");
        } catch (Exception e) {
        }
        return "success";
    }

}
